﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsFormsApplication2;
using WindowsFormsApplication2.Model;

namespace Anata_Client
{
    public partial class frmProduk : Form
    {
        ArrayList produk;
        ArrayList transaksiLayanan;
        ArrayList transaksiProduk;
        DataGridView dgvTransaksi;
        int Id;
        int idTransaksi;
        string Nama;

        public frmProduk(ref ArrayList _layanan, ref ArrayList _produk, int _idTransaksi , int _Id, string _Nama, DataGridView dgvHome)
        {
            InitializeComponent();

            object[] o = new object[2];
            Id = _Id;
            idTransaksi = _idTransaksi;
            Nama = _Nama;
            dgvTransaksi = dgvHome;
            transaksiLayanan = _layanan;
            transaksiProduk = _produk;
            produk = Aset.daftarAset(1);

            for (int i = 0; i < produk.Count; ++i)
            {
                o = (object[])produk[i];
                cmbProduk.Items.Add(o[1]);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            object[] o = new object[7];
            object[] p = new object[3];

            p = (object[])produk[cmbProduk.SelectedIndex];
            TransaksiProduk t = new TransaksiProduk();
            t.AddTransaksiProduk(idTransaksi, 7, (int)p[0]);

            o[0] = idTransaksi;
            o[1] = t.id;
            o[2] = Id;
            o[3] = Nama;
            o[4] = (string)p[1];
            o[5] = txtJumlah.Text;
            o[6] = (int)p[2] * Convert.ToInt32(txtJumlah.Text);

            transaksiProduk.Add(o);

            Form2 f = new Form2(ref transaksiLayanan, ref transaksiProduk, idTransaksi, Id, Nama, dgvTransaksi);
            f.Show();
            this.Close();
        }
    }
}
